:root {
    --bg-color: #f0f2f5;
    --sidebar-bg: #ffffff;
    --main-bg: #f7f7f8;
    --preview-bg: #ffffff;
    --border-color: #e5e7eb;
    --text-color: #111827;
    --text-secondary: #6b7280;
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --input-bg: #f9fafb;
    --success-color: #10b981;
    --error-color: #ef4444;
    --processing-color: #3b82f6;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.container { display: flex; width: 100%; height: 100%; }

/* --- 左侧边栏 --- */
.sidebar {
    width: 350px;
    flex-shrink: 0;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.header { padding-bottom: 16px; margin-bottom: 24px; border-bottom: 1px solid var(--border-color); }
.header h2 { margin: 0; }
.header p { margin: 4px 0 0; color: var(--text-secondary); }

.form-group { margin-bottom: 20px; }
label { display: block; font-weight: 500; margin-bottom: 8px; }

input[type="password"], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background-color: var(--input-bg);
    transition: border-color 0.2s;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

#generate-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: auto;
}
#generate-btn:hover { background-color: var(--primary-hover); }
#generate-btn:disabled { background-color: #9ca3af; cursor: not-allowed; }
#generate-btn .icon { width: 20px; height: 20px; }

/* --- 中间主内容 --- */
.main-content {
    flex-grow: 1;
    background-color: var(--main-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.history-header h3 { margin: 0; }
.sort-options { display: flex; align-items: center; gap: 8px; }

#history-list {
    overflow-y: auto;
    padding: 16px;
    flex-grow: 1;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.history-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.history-item.active { border-color: var(--primary-color); }

.history-item .thumbnail {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 6px;
    background-color: var(--input-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.history-item .thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.history-item .thumbnail .spinner { width: 24px; height: 24px; border-width: 3px; }

.history-item .info { flex-grow: 1; }
.history-item .info .prompt {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}
.history-item .info .meta { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.history-item .status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
}
.status.completed { background-color: var(--success-color); }
.status.processing { background-color: var(--processing-color); }
.status.failed { background-color: var(--error-color); }

/* --- 右侧预览 --- */
.preview-panel {
    width: 450px;
    flex-shrink: 0;
    background-color: var(--preview-bg);
    border-left: 1px solid var(--border-color);
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
#preview-image {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.preview-details h4 { margin-top: 0; }
.preview-details p { word-break: break-word; }

/* --- 通用组件 --- */
.placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary);
}
.hidden { display: none; }
.spinner {
    border: 5px solid rgba(0, 0, 0, 0.1);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border-left-color: var(--primary-color);
    animation: spin 1s ease infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
